<html>
<head><meta charset="utf-8"><title>Common shuffles · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html">Common shuffles</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236862700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236862700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236862700">(Apr 30 2021 at 16:28)</a>:</h4>
<p>Im implementing common shuffles per <a href="https://github.com/rust-lang/stdsimd/issues/93">https://github.com/rust-lang/stdsimd/issues/93</a>, i was thinking about adding both <code>rotate_left</code> and <code>rotate_right</code>, should i do that or stick to just <code>rotate</code> which rotates left?</p>



<a name="236862845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236862845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236862845">(Apr 30 2021 at 16:28)</a>:</h4>
<p>Also, should the factor be a <code>usize</code>?</p>



<a name="236864089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236864089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236864089">(Apr 30 2021 at 16:37)</a>:</h4>
<p>I have been using <code>u32</code> for Reasons.</p>



<a name="236864295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236864295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236864295">(Apr 30 2021 at 16:38)</a>:</h4>
<p>Alright, then i'll stick to <code>u32</code></p>



<a name="236864368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236864368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236864368">(Apr 30 2021 at 16:39)</a>:</h4>
<p>And I think that we should either have both <code>rotate_left</code> and <code>rotate_right</code> or we should accept an i32 and decide negative is one way and positive is the other way.</p>



<a name="236864474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236864474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236864474">(Apr 30 2021 at 16:39)</a>:</h4>
<p>I think considering the stdlib uses <code>rotate_left</code> and <code>rotate_right</code> in slices, we should just stick to that API for consistency</p>



<a name="236864493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236864493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236864493">(Apr 30 2021 at 16:39)</a>:</h4>
<p>Probably yes.</p>



<a name="236865422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236865422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236865422">(Apr 30 2021 at 16:46)</a>:</h4>
<p><code>simd_shuffle</code> uses u32 indices, so it's easier to just accept u32 because we can then just pass those through. u8s are not enough, but u16s probably would be.<br>
<code>std</code> often uses u32 as "a standard, small-sized value for talking about bits and bytes", even if logically we probably won't see more than a u8, e.g.<br>
<a href="https://doc.rust-lang.org/std/primitive.u32.html#method.rotate_right">https://doc.rust-lang.org/std/primitive.u32.html#method.rotate_right</a></p>



<a name="236865674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236865674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236865674">(Apr 30 2021 at 16:48)</a>:</h4>
<p>I see, makes sense</p>



<a name="236866080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236866080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236866080">(Apr 30 2021 at 16:51)</a>:</h4>
<p>how come shuffles use const generics instead of normal params?</p>



<a name="236866623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236866623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236866623">(Apr 30 2021 at 16:55)</a>:</h4>
<p>So, SIMD permutation like these are always slow compared to e.g. SIMD add or even load/store.<br>
But the fastest case assembly instructions tend to take immediates (const numbers) as inputs, so if we want the codegen to use those, we should provide constant values.</p>



<a name="236866717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236866717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236866717">(Apr 30 2021 at 16:56)</a>:</h4>
<p>Oh i see, makes sense <span aria-label="smiley" class="emoji emoji-1f603" role="img" title="smiley">:smiley:</span></p>



<a name="236866819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236866819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236866819">(Apr 30 2021 at 16:56)</a>:</h4>
<p>I just want to point out that I was unable to implement rotation.  Not to say it's impossible, but you run into an issue where you have dependent generic constants that rust (currently) can't handle</p>



<a name="236866852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236866852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236866852">(Apr 30 2021 at 16:57)</a>:</h4>
<p>Dynamic permutations exist that are still are faster than a lot of things, but because SIMD shuffles are <em>so slow</em>, we want to provide an API that cannot fail to pass a const value through, and to make it explicit when you use the dynamic vs. const shuffle.</p>



<a name="236866892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236866892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236866892">(Apr 30 2021 at 16:57)</a>:</h4>
<p>Hm, where did you encounter that?</p>



<a name="236867127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236867127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236867127">(Apr 30 2021 at 16:59)</a>:</h4>
<p>Well, if you assume the signature looks something like <code>fn rotate&lt;const N: usize&gt;</code> you get an issue when you try to convert N into the shuffle indices</p>



<a name="236867447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236867447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236867447">(Apr 30 2021 at 17:00)</a>:</h4>
<p>Perhaps there's a way to write it that doesn't have that issue, but that's what stopped me</p>



<a name="236867551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236867551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236867551">(Apr 30 2021 at 17:01)</a>:</h4>
<p>Do we need to make lane rotations const?</p>



<a name="236867625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236867625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236867625">(Apr 30 2021 at 17:02)</a>:</h4>
<p>I think that's like asking if we need to make shuffles const? There's a place for both</p>



<a name="236867745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236867745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236867745">(Apr 30 2021 at 17:02)</a>:</h4>
<p>Oh i see what you mean</p>



<a name="236867781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236867781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236867781">(Apr 30 2021 at 17:02)</a>:</h4>
<p>Yeah thats unfortunate, i think rotate will need to wait for that</p>



<a name="236867951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236867951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236867951">(Apr 30 2021 at 17:03)</a>:</h4>
<p>fair, I guess I was asking if we expect the instructions we lower to to be impacted in terms of performance</p>



<a name="236868228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868228">(Apr 30 2021 at 17:05)</a>:</h4>
<p>wait you can just add a generic to the function then call it with the outer generic lol</p>



<a name="236868308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868308">(Apr 30 2021 at 17:05)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">            </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">rotate_right</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">u32</span><span class="o">&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">idx</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">T</span>: <span class="kt">u32</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="cp">$n</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">base</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">crate</span>::<span class="n">permute</span>::<span class="n">base_index_array</span>::<span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="cp">$n</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">();</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="k">while</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">usize</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="n">last</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">base</span><span class="p">[</span><span class="cp">$n</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">];</span><span class="w"></span>
<span class="w">                        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="cp">$n</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>

<span class="w">                        </span><span class="k">while</span><span class="w"> </span><span class="n">j</span><span class="w"> </span><span class="o">&gt;</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                            </span><span class="n">base</span><span class="p">[</span><span class="n">j</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">base</span><span class="p">[</span><span class="n">j</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="mi">1</span><span class="p">];</span><span class="w"></span>
<span class="w">                            </span><span class="n">j</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">                        </span><span class="p">}</span><span class="w"></span>

<span class="w">                        </span><span class="n">base</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">last</span><span class="p">;</span><span class="w"></span>
<span class="w">                        </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
<span class="w">                    </span><span class="n">base</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>

<span class="w">                </span><span class="bp">self</span><span class="p">.</span><span class="n">shuffle</span>::<span class="o">&lt;</span><span class="p">{</span><span class="w"> </span><span class="n">idx</span>::<span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="o">&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="236868415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868415">(Apr 30 2021 at 17:06)</a>:</h4>
<p>wait it doesnt allow it nvm lmao</p>



<a name="236868452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868452">(Apr 30 2021 at 17:06)</a>:</h4>
<p>ah the pain, it didnt show the error because another function had an error <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="236868453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868453">(Apr 30 2021 at 17:06)</a>:</h4>
<p>Yeah I think that generic becomes too complicated for rust for some reason</p>



<a name="236868553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868553">(Apr 30 2021 at 17:07)</a>:</h4>
<p>i dont see why it has an issue with this, <code>this may fail depending on what value the parameter takes</code></p>



<a name="236868612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868612">(Apr 30 2021 at 17:07)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> I think we can do dynamic rotation because LLVM will probably do a very good job converting it to a static when possible</p>



<a name="236868776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868776">(Apr 30 2021 at 17:08)</a>:</h4>
<p>do you know if this is behind a feature/not implemented or if it will just never be allowed?</p>



<a name="236868790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868790">(Apr 30 2021 at 17:08)</a>:</h4>
<p>But we don't have any dynamic shuffles yet</p>



<a name="236868855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868855">(Apr 30 2021 at 17:08)</a>:</h4>
<p>Could maybe add <code>dynamic_shuffle</code>?</p>



<a name="236868884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868884">(Apr 30 2021 at 17:09)</a>:</h4>
<p>It's related to <code>const_evaluatable_checked</code> which is in the compiler but definitely incomplete</p>



<a name="236868931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868931">(Apr 30 2021 at 17:09)</a>:</h4>
<p>I see, so it will probably take a good amount of time for it to be allowed</p>



<a name="236868965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868965">(Apr 30 2021 at 17:09)</a>:</h4>
<p>Yeah I'm not really sure</p>



<a name="236868984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236868984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236868984">(Apr 30 2021 at 17:09)</a>:</h4>
<p>packed_simd had an implementation of <code>dyn_shuffle</code>.</p>



<a name="236869158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869158">(Apr 30 2021 at 17:10)</a>:</h4>
<p>i think <code>dynamic_shuffle</code> with a warning that this may be very slow could work</p>



<a name="236869460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869460">(Apr 30 2021 at 17:12)</a>:</h4>
<p>You may be able to implement static rotation with dynamic shuffles as a stopgap too</p>



<a name="236869506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869506">(Apr 30 2021 at 17:12)</a>:</h4>
<p>And I suspect it will compile to the same thing</p>



<a name="236869555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869555">(Apr 30 2021 at 17:13)</a>:</h4>
<p>as in convert the const params to non-const then call dyn shuffle? yeah that should work</p>



<a name="236869578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869578">(Apr 30 2021 at 17:13)</a>:</h4>
<p>Yeah exactly</p>



<a name="236869594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869594">(Apr 30 2021 at 17:13)</a>:</h4>
<p>in that case should i make dyn_shuffle private?</p>



<a name="236869613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869613">(Apr 30 2021 at 17:13)</a>:</h4>
<p>No, I think we want that in our public api too</p>



<a name="236869629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869629">(Apr 30 2021 at 17:13)</a>:</h4>
<p>Ok, so ill add both</p>



<a name="236869633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869633">(Apr 30 2021 at 17:13)</a>:</h4>
<p>We just haven't gotten around to it yet</p>



<a name="236869757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869757">(Apr 30 2021 at 17:14)</a>:</h4>
<p>Btw I think dynamic shuffling should look like how I did select (in the feature/select branch)</p>



<a name="236869840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869840">(Apr 30 2021 at 17:15)</a>:</h4>
<p>alright, ill check it out</p>



<a name="236869861"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869861" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869861">(Apr 30 2021 at 17:15)</a>:</h4>
<p>I think it should be a member fn of the index type and take the shuffle input as arguments</p>



<a name="236869945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869945">(Apr 30 2021 at 17:15)</a>:</h4>
<p>So <code>index.dyn_shuffle(a, b)</code> or whatever</p>



<a name="236869960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236869960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236869960">(Apr 30 2021 at 17:15)</a>:</h4>
<p>huh, why not just shuffle but with <code>indices: [u32; $n]</code>?</p>



<a name="236870098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870098">(Apr 30 2021 at 17:16)</a>:</h4>
<p>in that case do you mean an extension trait or on the actual primitive? i forget we are working on core itself <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="236870145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870145">(Apr 30 2021 at 17:16)</a>:</h4>
<p>I think that gets confusing fast. I actually don't love our current shuffle API because the two things you're shuffling are so separate in the API</p>



<a name="236870213"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870213" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870213">(Apr 30 2021 at 17:17)</a>:</h4>
<p>Take a look at how I did select, it's on the mask type but uses a trait to constrain the inputs</p>



<a name="236870241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870241">(Apr 30 2021 at 17:17)</a>:</h4>
<p>Alright</p>



<a name="236870268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870268">(Apr 30 2021 at 17:17)</a>:</h4>
<p>By the way, I think the index of dynamic shuffles is a simd vector with the same lane width and not an array (though it's basically the same)</p>



<a name="236870365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870365">(Apr 30 2021 at 17:18)</a>:</h4>
<p>oh right, ill use vector so its more explicit</p>



<a name="236870391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870391">(Apr 30 2021 at 17:18)</a>:</h4>
<p>hmm then in that case it would just be a method on the actual vectors</p>



<a name="236870410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870410">(Apr 30 2021 at 17:18)</a>:</h4>
<p>Yeah I think so</p>



<a name="236870493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870493">(Apr 30 2021 at 17:19)</a>:</h4>
<p>Yeah, shuffles basically tend to use SIMD vectors in the assembly, I used an array because that's the morally closest thing to a vector here.</p>



<a name="236870525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870525">(Apr 30 2021 at 17:19)</a>:</h4>
<p>Yeah and vectors arent allowed in const generics yet</p>



<a name="236870698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870698">(Apr 30 2021 at 17:20)</a>:</h4>
<p>Wait is core allowed to make vectors allowed in const generics? <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="236870720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870720">(Apr 30 2021 at 17:21)</a>:</h4>
<p>They actually would be allowed but I don't think it's necessary</p>



<a name="236870749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870749">(Apr 30 2021 at 17:21)</a>:</h4>
<p>There's nothing actually stopping us.</p>



<a name="236870773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870773">(Apr 30 2021 at 17:21)</a>:</h4>
<p>If it's const I think an array is better</p>



<a name="236870999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236870999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236870999">(Apr 30 2021 at 17:22)</a>:</h4>
<p>It actually took some compiler hacking to make monotuple arrays accepted.</p>



<a name="236871302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236871302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236871302">(Apr 30 2021 at 17:24)</a>:</h4>
<p>And it broke wasm32 inadvertently :)</p>



<a name="236871319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236871319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236871319">(Apr 30 2021 at 17:24)</a>:</h4>
<p>oh nice</p>



<a name="236871330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236871330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236871330">(Apr 30 2021 at 17:24)</a>:</h4>
<p>Still needs a bit more hacking</p>



<a name="236871625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236871625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236871625">(Apr 30 2021 at 17:26)</a>:</h4>
<p>I am waiting for the current kerfluffle around Wasm to die down before I pick up the axe re: that.</p>



<a name="236871751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236871751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236871751">(Apr 30 2021 at 17:27)</a>:</h4>
<p>for now i'll add a <code>dynamic_shuffle</code> method on vectors then have rotate call that</p>



<a name="236887086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236887086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236887086">(Apr 30 2021 at 19:14)</a>:</h4>
<p>Examples in stuff like interleave doesnt use <code># Examples</code>, is this intentional?</p>



<a name="236887718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236887718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236887718">(Apr 30 2021 at 19:19)</a>:</h4>
<p>Nope</p>



<a name="236888422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236888422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236888422">(Apr 30 2021 at 19:25)</a>:</h4>
<p>they also seem to use <code># use core_simd::SimdU32;</code> for some odd reason</p>



<a name="236888556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236888556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236888556">(Apr 30 2021 at 19:26)</a>:</h4>
<p>That's necessary because in the end it will be exposed as std::simd, not core_simd</p>



<a name="236888666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236888666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236888666">(Apr 30 2021 at 19:27)</a>:</h4>
<p>Ah ok, so ill use <code># Examples</code> and that for the meantime</p>



<a name="236888706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236888706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236888706">(Apr 30 2021 at 19:27)</a>:</h4>
<p>although examples get compiled during tests so that might not be desireable for now</p>



<a name="236888810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236888810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236888810">(Apr 30 2021 at 19:28)</a>:</h4>
<p>We definitely want them compiled.  But I think all doc tests will, regardless of an Examples section?</p>



<a name="236888863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236888863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236888863">(Apr 30 2021 at 19:28)</a>:</h4>
<p>I cant remember actually lol</p>



<a name="236895438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236895438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236895438">(Apr 30 2021 at 20:18)</a>:</h4>
<blockquote>
<p><code>shift (like rotate but insert 0s)</code></p>
</blockquote>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> don't intrinsics specifically made for this exist already? why is this under shuffles?</p>



<a name="236896066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896066">(Apr 30 2021 at 20:23)</a>:</h4>
<p>I mean [1, 2, 3, 4] -&gt; [0, 0, 1, 2]</p>



<a name="236896080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896080">(Apr 30 2021 at 20:23)</a>:</h4>
<p>Not bitwise operations</p>



<a name="236896255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896255">(Apr 30 2021 at 20:24)</a>:</h4>
<p>right, i thought operations for that existed already for things like 32 or 64 bit numbers</p>



<a name="236896733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896733">(Apr 30 2021 at 20:28)</a>:</h4>
<p>I could be wrong but I don't think there are intrinsics for that</p>



<a name="236896755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896755">(Apr 30 2021 at 20:28)</a>:</h4>
<p>I think the shuffle intrinsic is the only one that can move things across lanes like that</p>



<a name="236896789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896789">(Apr 30 2021 at 20:29)</a>:</h4>
<p><a href="https://software.intel.com/sites/landingpage/IntrinsicsGuide/#techs=SSE,SSE2,SSE3,SSSE3,SSE4_1,SSE4_2,AVX&amp;expand=4912,3864,743,743,3869&amp;cats=Shift">these instructions</a></p>



<a name="236896943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896943">(Apr 30 2021 at 20:30)</a>:</h4>
<p>btw i submitted the draft for rotate <a href="https://github.com/rust-lang/stdsimd/pull/111">#111</a></p>



<a name="236896967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236896967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236896967">(Apr 30 2021 at 20:30)</a>:</h4>
<p>Oh yes, that's why I want to provide them as a specific function.  It's something the compiler can likely do a very good job optimizing.</p>



<a name="236897007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897007">(Apr 30 2021 at 20:30)</a>:</h4>
<p>But there's no way to represent that in LLVM IR other than a shuffle</p>



<a name="236897010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897010">(Apr 30 2021 at 20:30)</a>:</h4>
<p>Oh ok, so relying on llvm to figure out it can be turned into those, got it</p>



<a name="236897022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897022">(Apr 30 2021 at 20:30)</a>:</h4>
<p>ah i see</p>



<a name="236897071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897071">(Apr 30 2021 at 20:31)</a>:</h4>
<p>makes sense, although not sure how to write that as a shift, a shift then a bitmask?</p>



<a name="236897335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897335">(Apr 30 2021 at 20:33)</a>:</h4>
<p>well, how to implement it in a way that will make llvm notice it</p>



<a name="236897483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897483">(Apr 30 2021 at 20:34)</a>:</h4>
<p>Well shuffle takes two vectors</p>



<a name="236897506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897506">(Apr 30 2021 at 20:34)</a>:</h4>
<p>I think you can just splat a new vector to zero for the second input</p>



<a name="236897860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897860">(Apr 30 2021 at 20:37)</a>:</h4>
<p>Oh i see, if the operation is shifting <code>[2, 3]</code> to the right once then just generate indices of <code>[2, 0]</code> where the second vector is a zero-vector</p>



<a name="236897915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897915">(Apr 30 2021 at 20:38)</a>:</h4>
<p>should this be a <code>Shl</code> impl or a normal function?</p>



<a name="236897997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236897997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236897997">(Apr 30 2021 at 20:38)</a>:</h4>
<p>I think a regular function, Shl is already used for bitwise shifts</p>



<a name="236898028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898028">(Apr 30 2021 at 20:39)</a>:</h4>
<p>Alright, so ill just do the same as rotate and add shift_left and shift_right</p>



<a name="236898072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898072">(Apr 30 2021 at 20:39)</a>:</h4>
<p>I wonder if we want to call it shift_lanes_left etc, just so it's clear what it's doing</p>



<a name="236898077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898077">(Apr 30 2021 at 20:39)</a>:</h4>
<p>Same with rotate</p>



<a name="236898161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898161">(Apr 30 2021 at 20:40)</a>:</h4>
<p>hmm, i think <code>rotate_bits_right</code> and stuff would be clearer if we ever add that since the most common use case is on lanes</p>



<a name="236898244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898244">(Apr 30 2021 at 20:41)</a>:</h4>
<p>Hmm perhaps.  I'm not actually sure which is more common but open to bike shedding it</p>



<a name="236898262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898262">(Apr 30 2021 at 20:41)</a>:</h4>
<p>does shuffle allow you to refer to the same index more than once?</p>



<a name="236898276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898276">(Apr 30 2021 at 20:41)</a>:</h4>
<p>I believe so</p>



<a name="236898288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898288">(Apr 30 2021 at 20:41)</a>:</h4>
<p>if so i'll just use the same index for all 0s</p>



<a name="236898379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898379">(Apr 30 2021 at 20:42)</a>:</h4>
<p>You could actually use a lane count of 1 for the zero vector, I think</p>



<a name="236898399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898399">(Apr 30 2021 at 20:42)</a>:</h4>
<p>At least the intrinsic supports that (not necessarily our shuffle function)</p>



<a name="236898434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898434">(Apr 30 2021 at 20:43)</a>:</h4>
<p>But I doubt it actually makes a difference</p>



<a name="236898469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898469">(Apr 30 2021 at 20:43)</a>:</h4>
<p>lane count is just a type system lie anyways so i dont think it would make a difference</p>



<a name="236898566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898566">(Apr 30 2021 at 20:44)</a>:</h4>
<p>man reading the docs with rustdoc not autoexpanding impl blocks is incredibly painful</p>



<a name="236898600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898600">(Apr 30 2021 at 20:44)</a>:</h4>
<p>Was that a change to rustdoc? I've noticed that happening only recently</p>



<a name="236898635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898635">(Apr 30 2021 at 20:44)</a>:</h4>
<p>i asked the rustdoc folks and they said its a bug</p>



<a name="236898658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898658">(Apr 30 2021 at 20:45)</a>:</h4>
<p>Ah makes sense</p>



<a name="236898722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898722">(Apr 30 2021 at 20:45)</a>:</h4>
<p>hmm i dont think i can use splat with 0 since this wouldnt work for float vectors</p>



<a name="236898753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898753">(Apr 30 2021 at 20:45)</a>:</h4>
<p>think i need to call the intrinsic manually with a constant type vector</p>



<a name="236898965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898965">(Apr 30 2021 at 20:47)</a>:</h4>
<p>Oh you can use Default instead of 0</p>



<a name="236898983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236898983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236898983">(Apr 30 2021 at 20:47)</a>:</h4>
<p>oh i can? sweet</p>



<a name="236899008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899008">(Apr 30 2021 at 20:47)</a>:</h4>
<p>Alternatively <code>0 as _</code> I think</p>



<a name="236899087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899087">(Apr 30 2021 at 20:48)</a>:</h4>
<p>btw why dont 256 bit types exist?</p>



<a name="236899130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899130">(Apr 30 2021 at 20:48)</a>:</h4>
<p>Like integers? No clue</p>



<a name="236899151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899151">(Apr 30 2021 at 20:48)</a>:</h4>
<p>We ran into issues with just 128 bit integers</p>



<a name="236899159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899159">(Apr 30 2021 at 20:48)</a>:</h4>
<p>oh boy</p>



<a name="236899194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899194">(Apr 30 2021 at 20:48)</a>:</h4>
<p>yeah avx2 is pretty common so its pretty important to look at adding them eventually</p>



<a name="236899280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899280">(Apr 30 2021 at 20:49)</a>:</h4>
<p>avx512 is very rare so it doesnt have to be a priority but it should be supported (i work with HPC clusters with xeons so it would be nice for that <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span>)</p>



<a name="236899415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899415">(Apr 30 2021 at 20:50)</a>:</h4>
<p>So i128 doesn't actually use SSE if that's what you're hinting at</p>



<a name="236899459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899459">(Apr 30 2021 at 20:50)</a>:</h4>
<p>It uses arithmetic carry operations</p>



<a name="236899489"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899489" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899489">(Apr 30 2021 at 20:50)</a>:</h4>
<p>So it's still handled 64 bits at a time</p>



<a name="236899726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899726">(Apr 30 2021 at 20:52)</a>:</h4>
<p>hmm not sure how to say this but id like some way of handling 128 or 256 bit vectors as a whole, without em being split into like, 2 u64s</p>



<a name="236899826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899826">(Apr 30 2021 at 20:53)</a>:</h4>
<p>although that gets a bit weird because you wouldnt have lanes for them, so they would be special types</p>



<a name="236899841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899841">(Apr 30 2021 at 20:53)</a>:</h4>
<p>but i think <code>SimdU128</code> should definitely exist</p>



<a name="236899997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236899997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236899997">(Apr 30 2021 at 20:55)</a>:</h4>
<p>Especially 128 bit and 256 bit bitmasks, which is what i often end up using simd for</p>



<a name="236900053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236900053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236900053">(Apr 30 2021 at 20:55)</a>:</h4>
<p>So I guess the question though, is there any reason you couldn't just use a smaller type for that? If it's just bitwise operations</p>



<a name="236900122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236900122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236900122">(Apr 30 2021 at 20:56)</a>:</h4>
<p>Well i think it would be kind of painful for certain operations, but i havent explored the API enough</p>



<a name="236900149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236900149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236900149">(Apr 30 2021 at 20:56)</a>:</h4>
<p>Integers over 64 bits get complicated when you get to arithmetic because basically nothing has hardware support for that, especially in simd</p>



<a name="236900176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236900176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236900176">(Apr 30 2021 at 20:56)</a>:</h4>
<p>yeah you're right</p>



<a name="236902263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236902263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236902263">(Apr 30 2021 at 21:05)</a>:</h4>
<p>oof just realized we cant add shift either until the rotate const generic issue is fixed <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="236904048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236904048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236904048">(Apr 30 2021 at 21:14)</a>:</h4>
<p>Haha yep.  It can probably use the same dynamic shuffle trick for now too, though</p>



<a name="236904202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236904202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236904202">(Apr 30 2021 at 21:15)</a>:</h4>
<p>this is definitely the worst const fn ive ever written, the funny thing is i wrote this to shift to the left, but its actually shifting to the right, so i guess ill just use this for shift_right <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">                </span><span class="k">const</span><span class="w"> </span><span class="k">fn</span> <span class="nf">idx</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="cp">$n</span><span class="p">]</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">base</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="cp">$n</span><span class="p">;</span><span class="w"> </span><span class="cp">$n</span><span class="p">];</span><span class="w"></span>
<span class="w">                    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">N</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="k">while</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="cp">$n</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                        </span><span class="n">base</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="kt">u32</span><span class="p">;</span><span class="w"></span>
<span class="w">                        </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">                    </span><span class="p">}</span><span class="w"></span>
<span class="w">                    </span><span class="n">base</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="236905448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236905448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236905448">(Apr 30 2021 at 21:21)</a>:</h4>
<p>Lol, whatever works</p>



<a name="236905600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236905600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236905600">(Apr 30 2021 at 21:22)</a>:</h4>
<p>oh i just forgot <code>base[i - $n]</code> haha</p>



<a name="236907809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236907809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236907809">(Apr 30 2021 at 21:38)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=9bcb321f7e2f9f80f77ad4e294fef63f">https://play.rust-lang.org/?version=nightly&amp;mode=release&amp;edition=2018&amp;gist=9bcb321f7e2f9f80f77ad4e294fef63f</a></p>



<a name="236907914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236907914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236907914">(Apr 30 2021 at 21:40)</a>:</h4>
<p>haha, that should work, what a hack though</p>



<a name="236907931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236907931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236907931">(Apr 30 2021 at 21:40)</a>:</h4>
<p>^ rotate using macros</p>



<a name="236907962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236907962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Riccardo D&#x27;Ambrosio <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236907962">(Apr 30 2021 at 21:40)</a>:</h4>
<p>i mean, stdsimd is already 80% macros</p>



<a name="236916713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236916713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236916713">(Apr 30 2021 at 23:25)</a>:</h4>
<p>it's true.</p>



<a name="236945535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/236945535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#236945535">(May 01 2021 at 07:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="276242">Riccardo D'Ambrosio</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Common.20shuffles/near/236899726">said</a>:</p>
<blockquote>
<p>hmm not sure how to say this but id like some way of handling 128 or 256 bit vectors as a whole, without em being split into like, 2 u64s</p>
</blockquote>
<p>I would <em>like</em> there to be a "bit" type, and for us to be able to have like <code>SimdBits&lt;128&gt;</code>, but that's basically "future extension of Rust" territory.</p>



<a name="237601988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Common%20shuffles/near/237601988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Common.20shuffles.html#237601988">(May 06 2021 at 04:01)</a>:</h4>
<blockquote>
<p>Swizzling using variable indices</p>
<p>i8x16.swizzle(a: v128, s: v128) -&gt; v128</p>
<p>Returns a new vector with lanes selected from the lanes of the first input vector a specified in the second input vector s. The indices i in range [0, 15] select the i-th element of a. For indices outside of the range the resulting lane is initialized to 0.</p>
</blockquote>
<div class="codehilite" data-code-language="Python"><pre><span></span><code><span class="k">def</span> <span class="nf">S</span><span class="o">.</span><span class="n">swizzle</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">s</span><span class="p">):</span>
    <span class="n">result</span> <span class="o">=</span> <span class="n">S</span><span class="o">.</span><span class="n">New</span><span class="p">()</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">S</span><span class="o">.</span><span class="n">Lanes</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">&lt;</span> <span class="n">S</span><span class="o">.</span><span class="n">lanes</span><span class="p">:</span>
            <span class="n">result</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">a</span><span class="p">[</span><span class="n">s</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">result</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">return</span> <span class="n">result</span>
</code></pre></div>
<p>Hey, wasm calls it a swizzle. :^)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>